3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
QuickDraw 3D provides routines that you can use to create and manipulate controller objects.
Some of these functions are intended for use only by controller device drivers. You should not call those functions from within applications.
You can use the Q3Controller_New function to create a new controller.
TQ3ControllerRef Q3Controller_New (
const TQ3ControllerData *controllerData);
The Q3Controller_New function returns, as its function result, a reference to a new controller object having the characteristics specified by the controllerData parameter. The new controller object is initially made active and is associated with the system cursor's tracker. You can call Q3Controller_SetTracker to associate the controller with some other tracker. The serial number of the new controller object is set to 1. If Q3Controller_New cannot create a new controller, it returns NULL .
You cannot delete a controller, but you can make it no longer operational. See the description of Q3Controller_Decommission ( [link] ) for details.
In general, you need to use this function only if you are writing a device driver for a controller.
See "Controller Data Structure" for a description of the fields of the controller data structure.
You can use the Q3Controller_GetListChanged function to determine whether the list of available controllers has changed.
TQ3Status Q3Controller_GetListChanged (
TQ3Boolean *listChanged,
unsigned long *serialNumber);
The Q3Controller_GetListChanged function returns, in the listChanged parameter, a Boolean value that indicates whether the list of available controllers has changed since the time the serial number passed in the serialNumber parameter was generated. If the list has changed, the new serial number is returned in the serialNumber parameter; otherwise, the serialNumber parameter is unchanged.
You can use the Q3Controller_Next function to read through the list of available controllers.
TQ3Status Q3Controller_Next (
TQ3ControllerRef controllerRef,
TQ3ControllerRef *nextControllerRef);
The Q3Controller_Next function returns, in the nextControllerRef parameter, a reference to the controller that immediately follows the controller specified by the controllerRef parameter. To get the first controller in the list, pass the value NULL in the controllerRef parameter. If the controller specified by the controllerRef parameter is the last controller in the list, nextControllerRef is set to NULL .
You can use the Q3Controller_Decommission function to make a controller inactive.
TQ3Status Q3Controller_Decommission (TQ3ControllerRef controllerRef);
The Q3Controller_Decommission function makes the controller specified by the controllerRef parameter inactive. Any remaining references to a controller that has been decommissioned are still valid, but the controller is no longer operational. (In other words, when the specified controller is referred to by an application or process other than the one that created it, reasonable default values are returned, not kQ3Failure .) Decommissioning a controller might cause the notify function of the tracker currently associated with the specified controller to be called.
You can use the Q3Controller_GetActivation function to get the activation state of a controller.
TQ3Status Q3Controller_GetActivation (
TQ3ControllerRef controllerRef,
TQ3Boolean *active);
You can use the Q3Controller_SetActivation function to set the activation state of a controller.
TQ3Status Q3Controller_SetActivation (
TQ3ControllerRef controllerRef,
TQ3Boolean active);
The Q3Controller_SetActivation function sets the activation state of the controller specified by the controllerRef parameter to the value specified in the active parameter. If the activation state of a controller is changed, the serial number of the list of available controllers is incremented. A controller should be inactive if it is temporarily off-line.
The notify function of the tracker currently associated with the specified controller might be called when Q3Controller_SetActivation is called.
You can use the Q3Controller_GetSignature function to get the signature of a controller.
TQ3Status Q3Controller_GetSignature (
TQ3ControllerRef controllerRef,
char *signature,
unsigned long numChars);
The Q3Controller_GetSignature function returns, through the signature parameter, the signature of the controller specified by the controllerRef parameter. You are responsible for allocating a buffer whose address is passed in the signature parameter and whose size is passed in the numChars parameter. If the signature is larger than the specified size, the signature is truncated to fit in the buffer.
You can use the Q3Controller_GetChannel function to get a controller channel.
TQ3Status Q3Controller_GetChannel (
TQ3ControllerRef controllerRef,
unsigned long channel,
void *data,
unsigned long *dataSize);
The Q3Controller_GetChannel function returns, through the data parameter, the current controller channel specified by the controllerRef and channel parameters. You are responsible for allocating memory for the data buffer and passing the size of that buffer in the dataSize parameter. Q3Controller_GetChannel returns, in the dataSize parameter, the number of bytes written to the data buffer.
You can use the Q3Controller_SetChannel function to set a controller channel.
TQ3Status Q3Controller_SetChannel (
TQ3ControllerRef controllerRef,
unsigned long channel,
const void *data,
unsigned long dataSize);
You can use the Q3Controller_GetValueCount function to get the number of values of a controller.
TQ3Status Q3Controller_GetValueCount (
TQ3ControllerRef controllerRef,
unsigned long *valueCount);
You can use the Q3Controller_SetTracker function to set the tracker associated with a controller.
TQ3Status Q3Controller_SetTracker (
TQ3ControllerRef controllerRef,
TQ3TrackerObject tracker);
The Q3Controller_SetTracker function associates the tracker specified by the tracker parameter with the controller specified by the controllerRef parameter. If the value of the tracker parameter is NULL , the controller is attached to the system cursor tracker. Changing a controller's tracker might cause the notify functions of both the previous tracker and the new tracker to be called.
You can use the Q3Controller_HasTracker function to determine whether a controller is currently associated with a tracker.
TQ3Status Q3Controller_HasTracker (
TQ3ControllerRef controllerRef,
TQ3Boolean *hasTracker);
You can use the Q3Controller_Track2DCursor function to determine whether a controller is currently affecting the two-dimensional system cursor.
TQ3Status Q3Controller_Track2DCursor (
TQ3ControllerRef controllerRef,
TQ3Boolean *track2DCursor);
The Q3Controller_Track2DCursor function returns, in the track2DCursor parameter, a Boolean value that indicates whether the controller specified by the controllerRef parameter is currently affecting the two-dimensional system cursor but the z axis values and orientation of the system cursor tracker are being ignored. If the specified controller is not attached to the system cursor tracker or if that controller is inactive, track2DCursor is set to kQ3False .
You can use the Q3Controller_Track3DCursor function to determine whether a controller is currently affecting the depth information also being used with the system cursor.
TQ3Status Q3Controller_Track3DCursor (
TQ3ControllerRef controllerRef,
TQ3Boolean *track3DCursor);
The Q3Controller_Track3DCursor function returns, in the track3DCursor parameter, a Boolean value that indicates whether the controller specified by the controllerRef parameter is currently affecting the two-dimensional system cursor and the z axis values and orientation of the system cursor tracker are not being ignored. If the specified controller is not attached to the system cursor tracker or if that controller is inactive, track3DCursor is set to kQ3False .
You can use the Q3Controller_GetButtons function to get the button state of a controller.
TQ3Status Q3Controller_GetButtons (
TQ3ControllerRef controllerRef,
unsigned long *buttons);
You can use the Q3Controller_SetButtons function to set the button state of a controller.
TQ3Status Q3Controller_SetButtons (
TQ3ControllerRef controllerRef,
unsigned long buttons);
The Q3Controller_SetButtons function sets the button state of the controller specified by the controllerRef parameter to the button state value passed in the buttons parameter. If the specified controller is inactive, Q3Controller_SetButtons has no effect. Changing a controller's button state might cause the notify function of the tracker currently associated with that controller to be called.
You can use the Q3Controller_GetTrackerPosition function to get the position of a controller's tracker.
TQ3Status Q3Controller_GetTrackerPosition (
TQ3ControllerRef controllerRef,
TQ3Point3D *position);
The Q3Controller_GetTrackerPosition function returns, in the position parameter, the current position of the tracker associated with the controller specified by the controllerRef parameter. If no tracker is currently associated with that controller, Q3Controller_GetTrackerPosition returns the position of the system cursor's tracker. Q3Controller_GetTrackerPosition has no effect if the controller is inactive.
You can use the Q3Controller_SetTrackerPosition function to set the position of a controller's tracker.
TQ3Status Q3Controller_SetTrackerPosition (
TQ3ControllerRef controllerRef,
const TQ3Point3D *position);
The Q3Controller_SetTrackerPosition function changes the position of the tracker currently associated with the controller specified by the controllerRef parameter to the position specified in the position parameter. If no tracker is currently associated with that controller, Q3Controller_SetTrackerPosition changes the position of the system cursor's tracker. Q3Controller_SetTrackerPosition has no effect if the controller is inactive.
Calling Q3Controller_SetTrackerPosition might cause the notify function of the controller's tracker to be called.
You can use the Q3Controller_MoveTrackerPosition function to move a controller's tracker relative to its current position.
TQ3Status Q3Controller_MoveTrackerPosition (
TQ3ControllerRef controllerRef,
const TQ3Vector3D *delta);
The Q3Controller_MoveTrackerPosition function changes the position of the tracker currently associated with the controller specified by the controllerRef parameter by the relative amount specified in the delta parameter. If no tracker is currently associated with that controller, Q3Controller_MoveTrackerPosition changes the position of the system cursor's tracker relative to its current position. Q3Controller_MoveTrackerPosition has no effect if the controller is inactive.
Calling Q3Controller_MoveTrackerPosition might cause the notify function of the controller's tracker to be called.
You can use the Q3Controller_GetTrackerOrientation function to get the current orientation of a controller's tracker.
TQ3Status Q3Controller_GetTrackerOrientation (
TQ3ControllerRef controllerRef,
TQ3Quaternion *orientation);
The Q3Controller_GetTrackerOrientation function returns, in the orientation parameter, the current orientation of the tracker associated with the controller specified by the controllerRef parameter. If no tracker is currently associated with that controller, Q3Controller_GetTrackerOrientation returns the orientation of the system cursor's tracker. Q3Controller_GetTrackerOrientation has no effect if the controller is inactive.
You can use the Q3Controller_SetTrackerOrientation function to set the orientation of a controller's tracker.
TQ3Status Q3Controller_SetTrackerOrientation (
TQ3ControllerRef controllerRef,
const TQ3Quaternion *orientation);
The Q3Controller_SetTrackerOrientation function changes the orientation of the tracker currently associated with the controller specified by the controllerRef parameter to the orientation specified in the orientation parameter. If no tracker is currently associated with that controller, Q3Controller_SetTrackerOrientation changes the orientation of the system cursor's tracker. Q3Controller_SetTrackerOrientation has no effect if the controller is inactive.
Calling Q3Controller_SetTrackerOrientation might cause the notify function of the controller's tracker to be called.
You can use the Q3Controller_MoveTrackerOrientation function to reorient a controller's tracker relative to its current orientation.
TQ3Status Q3Controller_MoveTrackerOrientation (
TQ3ControllerRef controllerRef,
const TQ3Quaternion *delta);
The Q3Controller_MoveTrackerOrientation function changes the orientation of the tracker currently associated with the controller specified by the controllerRef parameter by the relative amount specified in the delta parameter. If no tracker is currently associated with that controller, Q3Controller_MoveTrackerOrientation changes the orientation of the system cursor's tracker relative to its current orientation. Q3Controller_MoveTrackerOrientation has no effect if the controller is inactive.
Calling Q3Controller_MoveTrackerOrientation might cause the notify function of the controller's tracker to be called.
You can use the Q3Controller_GetValues function to get the list of values of a controller.
TQ3Status Q3Controller_GetValues (
TQ3ControllerRef controllerRef,
unsigned long valueCount,
float *values,
TQ3Boolean *changed,
unsigned long *serialNumber);
The Q3Controller_GetValues function returns, in the values parameter, a pointer to an array that contains the current values for the controller specified in the controllerRef parameter. The valueCount parameter specifies the number of elements in the array (which you must already have allocated). Q3Controller_GetValues might fill in fewer elements if the controller does not support the specified number of values.
If the value of the serialNumber parameter is NULL , Q3Controller_GetValues fills in the values array and returns the value kQ3True in the changed parameter. Otherwise, the value specified in the serialNumber parameter is compared with the controller's current serial number. If the two serial numbers are identical, Q3Controller_GetValues leaves the values array and the serialNumber parameter unchanged and returns the value kQ3False in the changed parameter. If the two serial number differ, Q3Controller_GetValues fills in the values array, updates the serialNumber parameter, and returns the value kQ3True in the changed parameter.
If the specified controller is inactive, the values array and the changed parameter are unchanged.
You can use the Q3Controller_SetValues function to set the list of values of a controller.
TQ3Status Q3Controller_SetValues (
TQ3ControllerRef controllerRef,
const float *values,
unsigned long valueCount);
Previous | QD3D Book | Overview | Chapter Contents | Next |